<?php
class AdvertisementModel extends Model {
	public function get_primary_key() {
		return $this->primary_key = 'id'; //设置主键
	}
	public function get_fields() {
		return $this->get_table_fields();
	}

	/**
	 * 创建公益广告
	 * @param $data
	 * @return bool
	 */
	public function createPubad($data)
	{
		$time = time();
		$times = ($data['timelong']*60)/5;
		$param=array(
			'uid'=>$data['uid'],	//代理商id
			'ad_info'=>$data['ad_info'],	//广告内容
			'type'=>2,	//广告类型  1：商业广告  2：公益广告
			'status'=>1,
			'times'=>$times,	//播放次数
			'ad_begin_time'=>$time,
			'ad_end_time'=>$time + $data['timelong']*60,
			'create_time'=>$time,
			'update_time'=>$time,
		);
		$this->db->insert('ca_advertisement', $param);
		$insertId = $this->db->insert_id();
		if(empty($insertId)){
			return false;
		}
		return true;
	}
	
}